<template>
  <div class="activity-detail">
    <div class="activity-detail-head">
      <cp-nav-bar title="活动详情" />
    </div>
    <!-- <img :src="baseURL + activity?.fileList[0].filePath" alt=""> -->
    <van-swipe :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="(item, index) in activity?.fileList" :key="index">
        <img style="width: 100%;height: 240px;" :src="baseURL + item.filePath" alt=""></van-swipe-item>
    </van-swipe>
    <p>{{ activity?.activityName }}</p>
    <div class="address">
      <span>{{ activity?.scenicMerchantName }}</span>
      <span @click="getphone">
        <cp-icon name="home-detail-phone" style="margin-right: 3px;"></cp-icon>
        <span style="color:#666; font-weight: 400; font-size: 12px;">电话</span>
      </span>
    </div>
    <div class="detailContent">
      <div v-html="activity?.activityContent">
      </div>
    </div>

  </div>
</template>
<script lang="ts" setup>
import { reactive, ref, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { getActivityById, } from "@/services/home";
import { baseURL } from '@/utils/request';
const router = useRouter()
const route = useRoute()
const activity = ref()

const getDetail = () => {
  getActivityById(route.query.id).then(res => {
    console.log('活动详情：', res);
    activity.value = res.data
  })
}

const callPhone = (phoneNumber) => {
  window.location.href = 'tel://' + phoneNumber
}

const getphone = () => {
  // showDialog({ message: `电话：${scenic.value.phone}` })
  callPhone(activity.value.phone)
}

onMounted(() => {
  getDetail()
})
</script>
<style scoped lang="scss">
.activity-detail {
  width: 375px;
  padding-top: 50px;
  min-height: calc(100vh - 50px);
  background-color: #f5f5f5;

  // img {
  //   width: 375px;
  //   height: 240px;
  // }

  &>p {
    margin: 15px 17px 0 17px;
    padding-bottom: 10px;
    color: #333333;
    font-size: 15px;
    font-weight: 700;
  }
  
  .address {
    display: flex;
    justify-content: space-between;
    align-items: center;
    // margin-top: 10px;
    // border-top: 1px solid #f5f5f5;
    font-size: 12px;
    font-weight: 400;
    color: #999999;
    padding: 6px 20px;
    border-bottom: 1px solid #DDDDDD;

    & span:nth-child(1) {
      width: 290px;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }

    & span:nth-child(2) {
      display: flex;
      align-items: center;
    }

    .cp-icon {
      width: 1.3em;
      height: 1.3em;
    }
  }

  .detailContent {
    margin: 0 17px;
    font-size: 12px;
    line-height: 20px;
    font-weight: 500;
    color: rgba(78, 89, 105, 1);
    padding: 7px 0;
  }
}

:deep(.detailContent img) {
  width: 100% !important;
}
</style>
